package main

import (
	"go.uber.org/zap"
)

func NewLogger() (*zap.Logger, error) {
	cfg := zap.NewProductionConfig()
	cfg.OutputPaths = []string{
		"./myproject.log",
		//"stderr",
	}
	cfg.ErrorOutputPaths = []string{
		"./error.log",
	}
	return cfg.Build()
}

func main()  {

	logger, err := NewLogger()
	if err != nil {
		panic(err)
	}

	defer logger.Sync() // flushes buffer, if any
	url := "http://kankan.meitu.com/"
	sugar := logger.Sugar()
	// 输出的时候
	//sugar.Infow("failed to fetch URL",
	//	// Structured context as loosely typed key-value pairs.
	//	"url", url,
	//	"attempt", 3,
	//	"backoff", time.Second,
	//)
	//sugar.Infof("Failed to fetch URL: %s", url)
	//sugar.Errorf("Failed to fetch URL: %s", url)

	logger.Info("Failed to fetch URL: %s",
		zap.String("url", url),
		zap.Int("number", 1),
	)
	sugar.Errorf("aaaaaa")

}
